package Autopeli;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.awt.Image;

/**
 *
 * @author Pasi
 */
public class Car {
    // auton alkutila
    private double angle;
    private int x;             
    private int y;
    private double speed;
    // vakioarvot
    private final double MAX_SPEED = 40;
    private final double MAX_ANGLE = 2.5;
    // kuva
    private Image image;

    public Car(Image image) {
        this.x = 50;
        this.y = 300;
        this.speed = 0;
        this.image = image;
    }
    
    public double getAngle() {return this.angle; }
    public int getX() { return this.x; }
    public int getY() { return this.y; }
    public double getSpeed() { return this.speed; }
    
    public void setAngle(double angle) {
        this.angle += angle;
        if (this.angle < -MAX_ANGLE) this.angle = -MAX_ANGLE;
        if (this.angle > MAX_ANGLE) this.angle = MAX_ANGLE;
    }
    public void resetAngle() { this.angle = 0.0;}
    public void setX(int x) { this.x = x; }
    public void setY(int y) { this.y = y; }
    public void setSpeed(double speed) { 
        this.speed += speed; 
        if (this.speed > MAX_SPEED) this.speed = MAX_SPEED; 
        if (this.speed < -MAX_SPEED) this.speed = -MAX_SPEED; 
        this.y -= this.speed;
    }
    public void resetSpeed() { this.speed = 0.0;}
    
    public Image getImage() { return this.image; }
}
